
//分享相关
var _title = '爱情先知，塔罗全预测';
var _desc = '问真心，看发展，想复合，做选择，爱情塔罗马上帮你';
var _link = websvr + '/sdkpack/sdktarot3/loading.html?biz_source=lxmtarotsdk3';
var _imgUrl = 'https://oj7h0vq33.qnssl.com/sdkpack/sdktarot/share.png';
var _dataUrl = '';

function initShareEx(title,desc,imagUrl,webURL) {
    _title = title;
    _desc =  desc;
    _imgUrl = imagUrl;
    _link = webURL;

    initShare();
}

function initShare() {
    var _shareObj = {
        title: _title,
        desc: _desc,
        link: _link,
        imgUrl: _imgUrl,
        type: 'link', // 分享类型,music、video或link，不填默认为link
        dataUrl: _dataUrl, // 如果type是music或video，则要提供数据链接，默认为空
        success: function () {},
        cancel: function (){},
        fail: function (res){}
    };

    if (wx && wx.ready) {
        wx.ready(function(){
            wx.onMenuShareTimeline(_shareObj);
            wx.onMenuShareAppMessage(_shareObj);
            wx.onMenuShareQQ(_shareObj);
            wx.onMenuShareWeibo(_shareObj);
            wx.onMenuShareQZone(_shareObj);
        });
    }

    if (wx && wx.error) {
        wx.error(function(res){});
    }

    $.ajax({
        type: 'post',
        url: httpsvr + '/oauth/wx/getconfig.do?url=' + encodeURIComponent(window.location.href),
        success: function(res) {
            var data;
            try {
                data = JSON.parse(res);
            } catch(e) {
                data = {};
            }
            if (data && data.var && data.var.signature && wx && wx.config) {
                wx.config({
                    appId: data.var.appId + '',
                    timestamp: data.var.timestamp + '',
                    nonceStr: data.var.nonceStr + '',
                    signature: data.var.signature + '',
                    jsApiList: [
                        'checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage',
                        'onMenuShareQQ', 'onMenuShareWeibo', 'hideMenuItems', 'showMenuItems',
                        'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem',
                        'translateVoice', 'startRecord', 'stopRecord', 'onRecordEnd',
                        'playVoice', 'pauseVoice', 'stopVoice', 'uploadVoice', 'downloadVoice',
                        'chooseImage', 'previewImage', 'uploadImage', 'downloadImage',
                        'getNetworkType', 'openLocation', 'getLocation',
                        'hideOptionMenu', 'showOptionMenu',
                        'closeWindow', 'scanQRCode', 'chooseWXPay',
                        'openProductSpecificView', 'addCard', 'chooseCard', 'openCard'
                    ]
                });
            }
        },
        error: function(msg) {}
    });


}